home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / samples / dpmi / dpmimem.c < prev    next >
C/C++ Source or Header  |  1993-08-08  |  2KB  |  53 lines

  1. #include <stdio.h>
  2. #include <dos.h>
  3. #include <go32.h>
  4. #include <dpmi.h>
  5.  
  6. char *comma(u_long val)
  7. {
  8.   static char buf2[30];
  9.   char buf1[30];
  10.   int i, j;
  11.   sprintf(buf1, "%12d", val);
  12.   for (j=0, i=0; i<12; i++)
  13.   {
  14.     buf2[j] = buf1[i];
  15.     j++;
  16.     if (i == 11)
  17.       break;
  18.     if (i%3 == 2)
  19.     {
  20.       if (buf1[i] != ' ')
  21.         buf2[j++] = ',';
  22.       else
  23.         buf2[j++] = ' ';
  24.     }
  25.   }
  26.   buf2[j++] = 0;
  27.   return buf2;
  28. }
  29.  
  30. int main()
  31. {
  32.   int i, pm, vm;
  33.   _go32_dpmi_meminfo meminfo;
  34.  
  35.   pm = _go32_dpmi_remaining_physical_memory();
  36.   vm = _go32_dpmi_remaining_virtual_memory();
  37.   _go32_dpmi_get_free_memory_information(&meminfo);
  38.  
  39.   printf("available memory          = %s\n", comma(meminfo.available_memory));
  40.   printf("available pages           = %s\n", comma(meminfo.available_pages));
  41.   printf("available lockable pages  = %s\n", comma(meminfo.available_lockable_pages));
  42.   printf("linear space              = %s\n", comma(meminfo.linear_space));
  43.   printf("unlocked pages            = %s\n", comma(meminfo.unlocked_pages));
  44.   printf("available physical memory = %s\n", comma(meminfo.available_physical_pages * 4096));
  45.   printf("total physical memory     = %s\n", comma(meminfo.total_physical_pages * 4096));
  46.   printf("free linear space         = %s\n", comma(meminfo.free_linear_space));
  47.   printf("size of paging file       = %s\n", comma(meminfo.max_pages_in_paging_file * 4096));
  48.   printf("remaining physical memory = %s\n", comma(pm));
  49.   printf("remaining virtual memory  = %s\n", comma(vm));
  50.   
  51.   return 0;
  52. }
  53.